package mao.exaimnation.huawei.huawei;



import java.util.Scanner;
//硬币找钱。
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count5,count10,count20;
        while (scanner.hasNext()){
            count5=0;
            count10=0;
            String s = scanner.nextLine();
            String[] split = s.split(",");
            int i=0;

            a: //标签的写法
            for ( i = 0; i < split.length ; i++) {
                switch (Integer.parseInt(split[i].trim())){
                    case 5:
                        count5++;
                        break;
                    case 10:
                        if (count5 <= 0){
                            System.out.println(false+","+(i+1));
                            break a ;
                        }else {
                            count5--;
                            count10++;
                        }
                        break;
                    case 20:
                        if (count5 >=3){
                            count5-=3;
                        }else if(count5 >=1 && count10>=1){
                            count5--;
                            count10--;
                        }else {
                            System.out.println(false+","+(i+1));
                            break a;
                        }
                        break ;
                    default:
                        System.out.println(false+","+(i+1));
                        break a;
                }
            }

            if (i==split.length){
                System.out.println(true+","+split.length);
            }
        }
    }
}
